<?php
/** @var TareaController $this */
/** @var Tarea $model */
/** @var AweActiveForm $form */
$form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
    'type' => 'horizontal',
    'id' => 'tarea-form',
    'enableAjaxValidation' => false,
    'clientOptions' => array('validateOnSubmit' => true, 'validateOnChange' => false,),
    'enableClientValidation' => true,
        ));
?>

<div class="span8">
    <div class="widget red">
        <div class="widget-title">
            <h4><i class="icon-tasks"></i> <?php echo Yii::t('AweCrud.app', $model->isNewRecord ? 'Create' : 'Update') . ' ' . Tarea::label(); ?></h4>
            <span class="tools">
                <a href="javascript:;" class="icon-chevron-down"></a>
                <!--a href="javascript:;" class="icon-remove"></a-->
            </span>
        </div>

        <div class="widget-body">
            <p class="note"><?php echo Yii::t('AweCrud.app', 'Fields with') ?> <span class="required">*</span> <?php echo Yii::t('AweCrud.app', 'are required') ?>.</p>

            <?php echo $form->textFieldRow($model, 'nombre', array('maxlength' => 64, 'class' => 'span8')) ?>
            <?php
            $entidades = $model->entidadTipoOpciones;
            if (count($entidades)):
                ?>
                <?php
                echo $form->dropDownListRow($model, 'entidad_tipo', $model->entidadTipoOpciones, array(
                    'empty' => '- Seleccione -',
                    'class' => 'span6 fix',
                    'ajax' => array(
                        'type' => 'POST',
                        'url' => 'cargarEntidades',
                        //'update'=>'#Tarea_entidad_id',
                        'success' => 'function(data) {$("#Tarea_entidad_id").html(data); $("#Tarea_entidad_id").selectBox("refresh");}'
                    )
                ));
                ?>
                <?php
                $data = array();
                if ($model->entidad_tipo) {
                    $modelEnt = ucfirst($model->entidad_tipo);
                    $data = $modelEnt::model()->activos()->findAll();
                    $data = CHtml::listData($data, 'id', $modelEnt::representingColumn());
                }
                ?>
                <?php echo $form->dropDownListRow($model, 'entidad_id', $data, array('class' => 'span6 fix')) ?>
            <?php endif; ?>


            <?php
            echo $form->dropDownListRow($model, 'etapa_id', CHtml::listData(TareaEtapa::model()->findAll(), 'id', TareaEtapa::representingColumn()), array('empty' => '- Seleccione -',
                'class' => 'span6 fix',
                'ajax' => array(
                    'type' => 'GET',
                    'data' => array('id_etapa' => 'js:$(this).val()'),
                    'url' => Yii::app()->createUrl('/tareas/tarea/ajaxGetPorcentaje/'),
                    'success' => 'function(data) {if(data){$("#Prob").val(data+"%"); }else{$("#Prob").val("");}}'
        )))
            ?>
            <?php echo $form->textFieldRow($model, 'porcentaje', array('class' => 'span4', 'readOnly' => 'True', 'id' => 'Prob', 'style' => "cursor: default")) ?> 
            <?php
            echo $form->datepickerRow($model, 'fecha_fin', array(
                'class' => 'span4',
                'options' => array(
                    'startDate' => 'today',
                    'language' => 'es',
                    'format' => 'dd/mm/yyyy',
                    'autoclose' => 'true',
                    'weekStart' => 1,
                    'keyboardNavigation' => true,
                ),
            ));
            ?>
            <?php echo $form->timepickerRow($model, 'hora_fin', array('class' => 'span4', 'options' => array('showMeridian' => false, 'defaultTime' => false))); ?>
            <?php echo $form->textAreaRow($model, 'descripcion', array('rows' => 3, 'class' => 'span8')) ?>

            <div class="form-actions">
                <div class="form-actions-float">
                    <?php
                    $this->widget('bootstrap.widgets.TbButton', array(
                        'buttonType' => 'submit',
                        'type' => 'success',
                        'icon' => 'ok',
                        'label' => $model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
                    ));
                    ?>
                    <?php
                    $this->widget('bootstrap.widgets.TbButton', array(
                        'icon' => 'remove',
                        'label' => Yii::t('AweCrud.app', 'Cancel'),
                        'htmlOptions' => array('onclick' => 'javascript:history.go(-1)')
                    ));
                    ?>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="span4">
    <div class="widget">
        <div class="widget-title">
            <h4><i class="icon-lock"></i> Permisos</h4>
            <span class="tools">
                <a href="javascript:;" class="icon-chevron-down"></a>
                <!--a href="javascript:;" class="icon-remove"></a-->
            </span>
        </div>
        <div class="widget-body permisos">
            <?php echo $form->dropDownListRow($model, 'owner_id', CHtml::listData(Yii::app()->user->um->listUsers(), 'iduser', 'username'), array('empty' => '- Seleccione -', 'class' => 'span12 fix')) ?>
            <div class="radio-list">
                <?php echo $form->radioButtonListRow($model, 'permisos', $model->permisosOpciones) ?>
            </div>
        </div>
    </div>
</div>
<?php $this->endWidget(); ?>
